package com.metaera.app.ui.adapters;

import android.content.Context;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.metaera.app.R;
import com.metaera.app.data.model.HomeTopNewsResponse;
import com.metaera.app.ui.activities.ArticleDetailsActivity;

import java.util.List;

import androidx.annotation.NonNull;

public class HomeRecommendNewsAdapter extends BaseQuickAdapter<HomeTopNewsResponse.RecommendLists, BaseViewHolder> {

    public HomeRecommendNewsAdapter(List<HomeTopNewsResponse.RecommendLists> data) {
        super(R.layout.item_news_home_recommend, data);

        setOnItemClickListener((adapter, view, position) -> {
            Context context = view.getContext();
            context.startActivity(ArticleDetailsActivity.newInstance(context, getItem(position).getId()));
        });
    }

    @Override
    protected void convert(@NonNull BaseViewHolder holder, HomeTopNewsResponse.RecommendLists item) {
        holder.setText(R.id.tv_title, item.getTitle());
    }

}
